﻿@model OT.Models.Users
@{
    ViewBag.Title = "Forgot Password";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<div class="container flex-main">
    <div class="row">
        <div class="col-md-12">

            <h3 id="myModalLabel">Forgot Password ?</h3>
            <div class="modal-body">
                <div class="row-fluid">
                    <div class="control-group">
                        <div class="form-horizontal">
                            <div id="divMsgIndex"></div>
                            <div class="form-group">
                                <label class="control-label col-lg-4" for="name">Enter Email ID</label>
                                <div class="col-lg-6">
                                    @Html.TextBoxFor(model => model.EmailAddress, new { @maxlength = "25", @class = "form-control" })
                                    @Html.ValidationMessageFor(model => model.EmailAddress)
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-lg-4"></div>
                            <label class="control-label col-lg-4" for="name">
                                <p>
                                    Type the Characters shown below.Use the Correct Case for Each Letter. If you Find it difficult too read ,
                              <b>click</b> the <b>REFRESH </b>Icon
                                </p>
                            </label>
                            <br />
                            @Html.Partial("Captcha")

                        </div>
                        <div class="form-group">
                            <div class="col-lg-2"></div>
                            <label class="control-label col-lg-4" style="text-align: right" for="name">Enter Captcha</label>
                            <div class="col-lg-4">
                                <input type="text" id="Captchainput" maxlength="5" class="form-control" />
                            </div>
                        </div>
                    </div>
                </div>
             
            </div>
            <div>
            </div>
               <div class="modal-footer">
                    <div id="msg" style="float: left"></div>
                    <button class="btn btn-danger" type="submit" id="btnretreive"><i class="icon-submit icon-white"></i>Retreive</button>
                  
                </div>

        </div>
    </div>
</div>

<script type="text/javascript">

    $('#EmailAddress').focusout(function () {
        $(".error33").hide();
        var nameRegex = new RegExp(/^([\w-\.]+)@@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/);
        var fname = $("#EmailAddress").val();
        if (!(nameRegex.test(fname))) {
            showMsg('divMsgIndex', 'Please enter valid Email Address.', 'danger');
        } else if (fname == " ") {
            showMsg('divMsgIndex', 'Please enter Email ID.', 'info');
        } else {
          
        }
    });


    $('#Captchainput').focusout(function () {
        $(".error5").hide();
        var cap = $("#Captchainput").val();
        if (cap == "") {
            showMsg('divMsgIndex', 'Please enter Captcha', 'info');
        } else {
            $.getJSON("/Home/CapValid", { cap: cap },
                function (res) {
                    if (res == "valid") {
                        showMsg('divMsgIndex', 'Captcha Input Is Valid', 'info');
                        $("#btnretreive").show();
                    }
                    else {
                        showMsg('divMsgIndex', 'In Valid Captcha Input', 'danger');
                        $("#btnretreive").hide();
                    }
                });
            return false;
        }
    });
    $(document).on("click", "#btnretreive", null, function (e) {
        var emailID = $("#EmailAddress").val();
        var captcha = $("#Captchainput").val();
        if (emailID == '' || captcha == '') {
            showMsg('divMsgIndex', 'Must Be Enter Required Value', 'danger');
        }
        else {
            $.getJSON("/Home/Retrieve", { emailID: emailID },
            function (res) {
                alert(res);
                if (res != "valid") {
                    showMsg('divMsgIndex', 'Please Try Again, Email Sending Failed', 'danger');
                }
                else {
                    showMsg('divMsgIndex', 'Please Check your Inbox', 'success');
                }
            })
        }
    });

</script>
